<template>
  <div class="goods-coment" v-if="Object.keys(goodsComent).length !== 0">
    <div class="top">
      <h3>用户评价</h3>
      <p>更多</p>
    </div>
    <div class="bd">
      <div class="user">
        <img :src="goodsComent.user.avatar" alt="" />
        <span>{{ goodsComent.user.uname }}</span>
      </div>
      <div class="coment">
        <p>{{ goodsComent.content }}</p>
      </div>
      <div class="comentInfos">
        <span>{{ goodsComent.created | showDate }}</span>
        <span>{{ goodsComent.style }}</span>
      </div>
      <div class="comentImg">
        <div :key="index" v-for="(item, index) in goodsComent.images">
          <img :src="item" alt="" />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { formatDate } from "common/formatDate";
export default {
  name: "DetailGoodsComent",
  props: {
    goodsComent: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  filters: {
    showDate(value) {
      const date = new Date(value * 1000);
      return formatDate(date, "yyyy-MM-dd");
    },
  },
};
</script>

<style scoped>
.goods-coment {
  margin: 30px 10px 0 10px;
}
.top {
  display: flex;
  justify-content: space-between;
  border-bottom: 2px solid #eee;
  padding-bottom: 10px;
}
.bd {
  margin-top: 10px;
}
.bd .user img {
  width: 15%;
  vertical-align: middle;
}
.bd .user span {
  /* display: block; */
  padding-left: 10px;
}
.coment {
  margin-top: 15px;
}
.comentInfos {
  margin-top: 5px;
  font-size: 14px;
}
.comentInfos span {
  padding-right: 10px;
}
.comentImg {
  margin-top: 10px;
  display: flex;
  justify-content: flex-start;
}
.comentImg img {
  width: 80px;
  margin-right: 15px;
}
</style>
